#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+5;
int T, n, m, l, V, d[N], v[N], a[N], p[N], ans;
struct node{
    int l, r;
}c[N];
bool cmp(node a, node b){
    return a.r==b.r?a.l<b.l:a.r<b.r;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>T;
    while(T--){
        ans=0;
        cin>>n>>m>>l>>V;
        for(int i=1; i<=n; i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=1; i<=m; i++)cin>>p[i];
        for(int i=1; i<=n; i++){
            if(a[i]>=0&&v[i]>V){
                int t1=lower_bound(p+1,p+1+m,d[i])-p, t2=m;
                if(t1<=t2)c[++ans]={t1,t2};
            }
            else if(a[i]>0){
                int ed=v[i]*v[i]+2*a[i]*(l-d[i]);
                if(ed>V*V){
                    int ll=(V*V-v[i]*v[i])/(2*a[i])+d[i];
                    int t1=upper_bound(p+1,p+1+m,ll)-p, t2=m;
                    if(t1<=t2)c[++ans]={t1,t2};
                }
            }
            else{
                if(v[i]>V){
                    int ll=(v[i]*v[i]-V*V)/(-2*a[i])+d[i];
                    if((V*V-v[i]*v[i])%(2*a[i])!=0)ll++;
                    // double ll=(V*V-v[i]*v[i])*1.0/(2*a[i])+d[i];
                    int t1=lower_bound(p+1,p+1+m,d[i])-p,t2=lower_bound(p+1,p+1+m,ll)-p-1;
                    if(t1<=t2)c[++ans]={t1,t2};
                }
            }
        }
        cout<<ans<<' ';
        // for(int i=1; i<=ans; i++)cout<<c[i].l<<' '<<c[i].r<<'\n';
        sort(c+1,c+1+ans,cmp);
        int ans2=0, las=-1;
        for(int i=1; i<=ans; i++){
            if(las<c[i].l)las=c[i].r,ans2++;
        }
        cout<<m-ans2<<'\n';
    }
    return 0;
}